package com.zz.hw;

import java.util.ArrayList;

public class TravelTree {

    public ArrayList PreTravel(TreeNode root){
        ArrayList<Integer> array = new ArrayList();
        if (root == null){
            return  array;
        }
        preTravel(root, array);
        return array;
    }

    public void preTravel(TreeNode root, ArrayList array){
        if (root == null){
            return;
        }
        array.add(root.value);
        preTravel(root.left,array);
        preTravel(root.right,array);
    }
}

class TreeNode{

    Integer value = 0;
    TreeNode left = null;
    TreeNode right = null ;
    public TreeNode(Integer val){
        this.value = val;
    }
}